import Qt 4.7
import EventInfo 1.0

Item {
    id: container

    signal returnTo

    width: parent.width
    height: parent.height

	function setEventInfo(index) {
        var info = eventsListModel.getEventInfo(index);
        var str = "<font size=\"+2\">" + info.name + "</font><br>"
                  + info.eventDate
                  + "<br><br>";

        var str2 = info.venuName;
        var str3 = "";

        if (info.venuName == "" || info.venuName == null) {
            str2 = "Not chosen yet";
        } else {
            str2 = "<a href=\"" + info.map + "\">" + info.venueName + "</a><br>";

            str3 = info.address1 + "<br>"
                  + info.city + ", " + info.state + " " + info.zipCode
                  + "<br><br>";
        }

        var str4 = "Description<br>"
                  + info.description;

        text.text = str;
        text2.text = "<b>Location</b><br>" + str2;
        text3.text = str3;
        text4.text = str4;

        itemIndex.text = index + " h:" + text.height + " " + info.name;
    }

    Item {
        id: eventDetailUI
        width: parent.width
        height: parent.height
        x: 0
        y: 0

        // background
        Rectangle {
            color: "#002200"
            anchors.fill: parent
        }

        // tool buttons
        Item {
            id: toolButtons
            width: parent.width
            height: 48
            anchors.top: parent.top

            Text {
                id: itemIndex
                anchors.left: parent.left
                y: 0
                width: text.width
                height: parent.height
                text: 	""
                color: "white"
                font.pointSize: fontSize
                wrapMode: Text.Wrap
            }

    /*
            Button {
                id: btnUpdate
                text: "Update"
                anchors.right: btnReturn.left
                anchors.leftMargin: -110
                y: 0
                width: 100
                height: 48
                onClicked: { eventsListModel.update() }
            }
    */
            Button {
                id: btnReturn
                text: "Return"
                anchors.right: parent.right
                y: 0
                width: 100
                height: parent.height
                onClicked: { container.returnTo() }
            }
        }

        ScrollBar {
            id: scrollbar
            scrollArea: textArea
            width: 4
            height: parent.height - toolButtons.height
            anchors.top: toolButtons.bottom
            anchors.right: parent.right
            clip: true
        }


        Flickable {
            id: textArea
            anchors.top: toolButtons.bottom
            anchors.left: parent.left
            anchors.right: scrollbar.left
            width: parent.width - scrollbar.width
            height: parent.height - toolButtons.height
            contentWidth: width
            contentHeight: text.height + text2.height + text3.height + text4.height
            clip: true

            Text {
                id: text
                text: ""
                wrapMode: Text.Wrap
                width: parent.width
                color:  "white"
                font.pointSize: fontSize
            }

            Text {
                id: text2
                text: ""
                wrapMode: Text.Wrap
                width: parent.width
                color:  "white"
                font.pointSize: fontSize
                anchors.top: text.bottom
            }

            Text {
                id: text3
                text: ""
                wrapMode: Text.Wrap
                width: parent.width
                color:  "white"
                font.pointSize: fontSize
                anchors.top: text2.bottom
            }

            Text {
                id: text4
                text: ""
                wrapMode: Text.Wrap
                width: parent.width
                color:  "white"
                font.pointSize: fontSize
                anchors.top: text3.bottom
            }
        }
    }
}
